<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>日例会录入</title>

    <% include ../../layouts/import.ejs %>

</head>
<body>
<% include ../../layouts/header.ejs %>
<div class="index container weekly-body">
    <div class="we-title row">
        <h2 class="col-md-4">日例会录入</h2>
    </div>

    <div class="we-btns clearfix">

        <a href="javascript:void(0)" class="btn btn-primary pull-left we-btn" id="addProCont">添加项目模块</a>

    </div>
    <div class="we-pros">
        <table class="table table-striped we-pro">
            <thead>
            <tr class="we-proname-box form-inline">
                <td class="form-grap  col-md-5" colspan="2" style="position: relative">
                    <select name="" id="" class="form-control we-pro-choose">
                        <option value="not">请选择项目</option>
                        <% for(var i = 0; i < projectList.length; i++) { %>
                        <option value="<%= projectList[i].id %>"><%= projectList[i].project_name %></option>
                        <% } %>
                    </select>
                    <a href="javascript:void(0)" title="修改项目名称" class="glyphicon glyphicon-edit we-pro-edit"></a>
                </td>
                <td class="form-grap  col-md-3" colspan="3">
                    <span class="we-proplan-ts">至少有一条项目记录，不可删除</span>
                </td>
                <td class="form-grap  col-md-4 ">
                    <a href="javascript:void (0)" class="btn btn-danger pull-right we-pro-delete">删除模块</a>
                </td>

            </tr>
            </thead>
            <tbody class="we-proplans">
            <tr class=" form-inline we-proplan">
                <td class="form-grap col-md-3">
                    <select name="" id="" class="form-control">
                        <option value="not">选择任务</option>
                        <option value="1">任务一</option>
                        <option value="2">任务二</option>
                        <option value="3">任务三</option>
                    </select>
                </td>
                <td class="form-grap col-md-2">
                    <input type="text" value="" placeholder="完成情况" class="form-control">
                </td>
                <td class="form-grap col-md-2">
                    <input type="text" value="创建人:齐富新" class="form-control" disabled>
                </td>
                <td class="form-grap col-md-2">
                    <input type="text" value="完成时间:2018-12-20" class="form-control" disabled>
                </td>
                <td class="form-grap col-md-1">
                    <select name="" id="" class="form-control inputPadd">
                        <option value="0">未完成</option>
                        <option value="1">完成</option>
                    </select>

                </td>
                <td class="form-grap col-md-2">
                    <a href="javascript:void(0)" title="删除"
                       class="glyphicon glyphicon-trash form-control we-proplan-delete"></a>
                    <a href="javascript:void(0)" title="添加"
                       class="glyphicon glyphicon-plus-sign form-control we-proplan-add"></a>
                </td>
            </tr>
            </tbody>

        </table>


    </div>
</div>
<script>
    //    $("body").click(function(e){
    //        var _con = $('.we-yypro-box');
    //        console.log( _con.css("display") );
    //        if (_con.css("display") == "block"){
    ////            if(!_con.is(e.target) && _con.has(e.target).length === 0){
    ////                _con.hide();
    ////                console.log(1);
    ////            }else{
    ////                console.log(2);
    ////            }
    //        }


    //    });


    function showYYprp() {
        $(".we-yypro-box").toggle();
    }

    function saveNewProname() {
        var newProname = $("#newProname").val();
        if (newProname == "") {
        }
        else {
            $(".we-yypro-list").append('<li>' + newProname + '</li>');
        }
    };
    $(function () {
        $("#addProCont").on("click", function () {
            $(".we-pros").append('<table class="table table-striped we-pro ">' +
                '<thead>' +
                '<tr class="we-proname-box form-inline">' +
                '<td class="form-grap  col-md-5" colspan="2" style="position: relative">' +
                '<select name="" id="" class="form-control we-pro-choose" >' +
                '<option value="not">请选择项目</option>' +
                '<option value="1">项目一</option>' +
                '</select>' +
                '<a href="javascript:void(0)" title="修改项目名称" class="glyphicon glyphicon-edit we-pro-edit"></a>' +

                '</td>' +
                '<td class="form-grap  col-md-3" colspan="3">' +
                '<span class="we-proplan-ts">至少有一条项目记录，不可删除</span>' +
                '</td>' +
                '<td class="form-grap  col-md-4 ">' +
                '<a href="javascript:void (0)"  class="btn btn-danger pull-right we-pro-delete ">删除模块</a>' +
                '</td>' +
                '</tr>' +
                '</thead>' +

                '<tbody class="we-proplans">' +
                '<tr class=" form-inline we-proplan">' +
                '<td class="form-grap col-md-3">' +
                '<select name="" id="" class="form-control">' +
                '<option value="not" >选择任务</option>' +
                '<option value="1" >任务一</option>' +
                '<option value="2" >任务二</option>' +
                '<option value="3" >任务三</option>' +
                '</select>' +
                '</td>' +
                '<td class="form-grap col-md-2">' +
                '<input type="text" value="" placeholder="完成情况" class="form-control">' +
                '</td>' +
                '<td class="form-grap col-md-2">' +
                '<input type="text" value="创建人:齐富新" class="form-control" disabled >' +
                '</td>' +
                '<td class="form-grap col-md-2">' +
                '<input type="text" value="完成时间:2018-12-20" class="form-control" disabled >' +
                '</td>' +
                '<td class="form-grap col-md-1">' +
                '<select name="" id="" class="form-control inputPadd">' +
                '<option value="0" >未完成</option>' +
                '<option value="1" >完成</option>' +
                '</select>' +

                '</td>' +
                '<td class="form-grap col-md-2">' +
                '<a href="javascript:void(0)" title="删除" class="glyphicon glyphicon-trash form-control we-proplan-delete"></a>' +
                '<a href="javascript:void(0)" title="添加" class="glyphicon glyphicon-plus-sign form-control we-proplan-add"></a>' +
                '</td>' +
                '</tr>' +
                '</tbody>' +
                '</table>'
            );
        });
        $("body").on("click", ".we-proplan-delete", function () {
            var outtimer;
            clearTimeout(outtimer);
            var thisWePro = $(this).parents(".we-pro");
            var plannum = thisWePro.find(".we-proplan").length;
            if (plannum < 2) {
                thisWePro.find(".we-proplan-ts").show();

                outtimer = setTimeout(function () {
                    thisWePro.find(".we-proplan-ts").hide();
                }, 5000)
            } else {
                $(this).parents(".we-proplan").remove();
            }

        });

        $("body").on("blur", ".we-pro-choose", function () {
            var thisSelete = $(this);
            var thisSeleteValue = $(this).val();
            if (thisSeleteValue == "not") {
                console.log("没选择");
                thisSelete.removeAttr("disabled", "").removeClass("we-pro-not");
                thisSelete.siblings(".we-pro-edit").hide();
            } else {
                console.log("选择");
                thisSelete.addClass("we-pro-not").attr("disabled", "disabled");
                thisSelete.siblings(".we-pro-edit").show();
            }
        });
        $("body").on("click", ".we-pro-edit", function () {
            var thisSelect = $(this).siblings(".we-pro-choose");
            thisSelect.removeAttr("disabled", "").removeClass("we-pro-not");
            $(this).hide();

        });
        $("body").on("click", ".we-proplan-add", function () {
            $(this).parents(".we-proplan").after(
                '<tr class=" form-inline we-proplan">' +
                '<td class="form-grap col-md-3">' +
                '<select name="" id="" class="form-control">' +
                '<option value="not" >选择任务</option>' +
                '<option value="1" >任务一</option>' +
                '<option value="2" >任务二</option>' +
                '<option value="3" >任务三</option>' +
                '</select>' +
                '</td>' +
                '<td class="form-grap col-md-2">' +
                '<input type="text" value="" placeholder="完成情况" class="form-control">' +
                '</td>' +
                '<td class="form-grap col-md-2">' +
                '<input type="text" value="创建人:" class="form-control" disabled >' +
                '</td>' +
                '<td class="form-grap col-md-2">' +
                '<input type="text" value="完成时间:" class="form-control" disabled >' +
                '</td>' +
                '<td class="form-grap col-md-1">' +
                '<select name="" id="" class="form-control inputPadd">' +
                '<option value="0" >未完成</option>' +
                '<option value="1" >完成</option>' +
                '</select>' +

                '</td>' +
                '<td class="form-grap col-md-2">' +
                '<a href="javascript:void(0)" title="删除" class="glyphicon glyphicon-trash form-control we-proplan-delete"></a>' +
                '<a href="javascript:void(0)" title="添加" class="glyphicon glyphicon-plus-sign form-control we-proplan-add"></a>' +
                '</td>' +
                '</tr>'
            );
        });
        $("body").on("click", ".we-pro-delete", function () {
            $(this).parents(".we-pro").remove();
        });


    });
</script>
</body>
</html>